/**
    算法描述：
    核心问题：
    解决所需数据结构+算法：
**/
#include<bits/stdc++.h>
using namespace std;
  
int a[500010] = {0}, n;
  
int lowbit(int x) {
    return x&(-x);
}
  
void add(int x, int p) {
    while(x<=n) {
        a[x] += p;
        x += lowbit(x);
    }
}
  
int sm(int x) {
    int cnt = 0;
    while(x>0) {
        cnt += a[x];
        x -= lowbit(x);
    }
    return cnt;
}
  
int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        memset(a, 0, sizeof(a));
        int m;
        scanf("%d%d", &n, &m);
        for (int i=1; i<=n; i++)
            add(i, 1);
        while(m--) {
            int o, x, y;
            scanf("%d", &o);
            if (o == 1) {
                scanf("%d%d", &x, &y);
                int tmin = min(x, y);
                int tmax = max(x, y);
                x = tmin; y = tmax;
//              cout <<x <<":"<<sm(x)<<endl;
//              cout <<y <<":"<<sm(y)<<endl;
                if ((sm(y-1) - sm(x-1) == y-x) || sm(n) - sm(y-1) + sm(x-1) == n-y+x)
                    printf("1\n");
                else printf("0\n");
            } else {
                scanf("%d", &x);
                if(sm(x)-sm(x-1) == 1)
                    add(x, -1);
                else add(x, 1);
            }
        }
        printf("\n");
    }
    return 0;
}